package com.ybbase.framework.service.flow.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ybbase.framework.mapper.flow.NodeActionMapper;
import com.ybbase.framework.mapper.flow.NodeConfigMapper;
import com.ybbase.framework.model.po.flow.ActionConfig;
import com.ybbase.framework.mapper.flow.ActionConfigMapper;
import com.ybbase.framework.model.po.flow.NodeAction;
import com.ybbase.framework.service.flow.ActionConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 流程动作配置 服务实现类
 * </p>
 *
 * @author cg
 * @since 2019-12-04
 */
@Service
public class ActionConfigServiceImpl extends ServiceImpl<ActionConfigMapper, ActionConfig> implements ActionConfigService {

    @Autowired
    NodeConfigMapper nodeConfigMapper;
    @Autowired
    NodeActionMapper nodeActionMapper;
    @Autowired
    ActionConfigMapper actionConfigMapper;

    /**
     * 根据BusinessCode和GatewayCode查询流程节点动作列表
     * @param businessCode 业务流程代码也就是流程代码
     * @param gatewayCode 网关代码
     * @return List<ActionConfig>
     * @author cg
     * @date 2019-09-25 10:26
     * @since 4.0
     */
    @Override
    public List<ActionConfig> getActionListByCode(String businessCode, String gatewayCode) throws Exception {
        return actionConfigMapper.getActionListByCode(businessCode,gatewayCode);
    }

    /**
     * 通过网关获取动作列表
     * @param actionCode 动作编码
     * @return List<NodeAction>
     * @author cg
     * @date 2019-11-07 10:07
     * @since 4.0
     */
    @Override
    public List<NodeAction> getNodeActionList(String actionCode) throws Exception{
        QueryWrapper<NodeAction> nodeActionQueryWrapper = new QueryWrapper<>();
        nodeActionQueryWrapper.lambda().eq(NodeAction::getActionCode, actionCode);
        return nodeActionMapper.selectList(nodeActionQueryWrapper);
    }
}
